/**
 * 
 */
package com.hand.cloud.b2b.daos.impl;

import de.hybris.platform.catalog.enums.ArticleApprovalStatus;
import de.hybris.platform.catalog.model.CatalogModel;
import de.hybris.platform.catalog.model.CatalogVersionModel;
import de.hybris.platform.core.model.product.ProductModel;
import de.hybris.platform.servicelayer.ServicelayerTransactionalTest;

import javax.annotation.Resource;

import junit.framework.Assert;

import org.junit.Test;

import com.hand.cloud.b2b.daos.ProductDAO;
import com.hand.cloud.b2b.model.EPCatalogModel;
import com.hand.cloud.b2b.model.EPCatalogVersionModel;
import com.hand.cloud.b2b.model.EPProductModel;


/**
 * @author StephenWang
 * @time Aug 7, 2014 10:52:51 AM
 * 
 */
public class DefaultProductDAOTest extends ServicelayerTransactionalTest
{

	@Resource
	private ProductDAO productDAO;

	@Test
	public void testProductByCode()
	{
		ProductModel product = productDAO.getProductByCode("107701");
		Assert.assertNotNull(product);
	}

	@Test
	public void testProductByPk(){
	ProductModel product=productDAO.getProductByPK("8796230418433");	
	Assert.assertNotNull(product);
	}
	
	@Test
	public void testCreatProduct()
	{
   ProductModel product =productDAO.createProduct();
   System.out.print("productPk:"+product.getPk());
	}
	
	@Test
	public void testDeleteProduct()
	{
		this.productDAO.deleteProduct("107701");
	}
	
	@Test
	public void testModifyProduct()
	{
		ProductModel epproduct = new ProductModel();
		epproduct.setApprovalStatus(ArticleApprovalStatus.CHECK);

		CatalogModel catalog = new CatalogModel();
		catalog.setDefaultCatalog(Boolean.TRUE);
		catalog.setId("catalog1");

		CatalogVersionModel catalogversion = new CatalogVersionModel();
		catalogversion.setInclAssurance(Boolean.TRUE);
		catalogversion.setInclDuty(Boolean.TRUE);
		catalogversion.setInclFreight(Boolean.TRUE);
		catalogversion.setInclPacking(Boolean.TRUE);
		catalogversion.setVersion("catalogversion1");
		catalogversion.setCatalog(catalog);

		epproduct.setCatalogVersion(catalogversion);
		epproduct.setCode("637228");

		ProductModel product =productDAO.modifyProduct(epproduct);
		System.out.print("productPk:"+product.getPk());
	}

}
